#include <iostream>
#include <future>
#include <thread>
#include <unistd.h>

int Add(int n1, int n2)
    {
        std::cout<<"into add!\n";
        return n1 + n2;
    }

int main()
{
    std::future<int> ret =  std::async(std::launch::async, Add, 11, 22);
    // std::thread t1([](){
    //     sleep(1);
    // });
    std::this_thread::sleep_for(std::chrono::seconds(1));
    std::cout<<"--------------------"<<std::endl;
    //get 用于获取异步结果， 无结果则阻塞
    std::cout<< ret.get() << std::endl;
}